<!--
  @Descripttion:：简历编辑，通过抽屉弹出简历预览（特殊）
  @Author：yejianbo
  @Date：2022年07月11日
-->
<template>
  <PageCom :hideHeadFooter="true">
    <section class="resume-review">
      <!-- 个人基本信息 -->
      <section class="block">
        <div class="head-icon">
          <img
            class="touxiang"
            v-if="userInfo.studentPictureUrl"
            :src="userInfo.studentPictureUrl"
            alt="用户头像"
          />
          <img
            class="touxiang"
            v-else
            src="@/assets/images/touxiang1.png"
            alt="用户头像"
          />
          <el-button
            class="edit-btn"
            v-if="!hideEdit"
            @click="linkTo('resumeEdit')"
            >编辑</el-button
          >
        </div>
        <div class="user-info">
          <div class="row1">
            {{ userInfo.nickname }}
            <!-- <span>学生</span> -->
          </div>
          <div class="row2">
            {{ userInfo.sex }}<span class="line"></span>{{ userInfo.age
            }}<span class="line"></span>{{ userInfo.liveCity
            }}<span class="line"></span>{{ userInfo.clan }}
            <br />
            <div class="row3">
              <span class="label">手机号码</span>
              <el-tooltip
                class="item"
                effect="dark"
                :content="userMobile"
                placement="top-start"
              >
                <span class="label">{{ userMobile }}</span>
              </el-tooltip>
            </div>
            <div class="row4">
              <span class="label">邮箱地址</span>
              <el-tooltip
                class="item"
                effect="dark"
                :content="userInfo.email"
                placement="top-start"
              >
                <span class="label">{{ userInfo.email }}</span>
              </el-tooltip>
            </div>
          </div>
        </div>
      </section>
      <!-- 求职状态 -->
      <section class="block pt30">
        <p class="title">求职状态</p>
        <div class="job-wish-item">
          <div class="row1">
            <div class="row1">
              {{
                (userInfo.jobStatus || "--") +
                "/" +
                (userInfo.inJobTime || "--")
              }}
            </div>
          </div>
        </div>
      </section>
      <!-- 求职意向 -->
      <section class="block pt30">
        <p class="title">求职意向</p>
        <div
          class="job-wish-item"
          v-for="(item, index) in internshipDesire"
          :key="index"
        >
          <div class="row1">
            {{ item.jobName }}<span class="line"></span
            >{{ item.lowestSalary }}-{{ item.highestSalary }}元/天<span
              class="line"
            ></span
            >{{ item.targetCity }}
          </div>
          <div
            class="job-type"
            v-for="(it, i) in item.expectedIndustry"
            v-show="it"
            :key="i"
          >
            {{ it }}
          </div>
        </div>
      </section>
      <!-- 教育经历 -->
      <section class="block pt30">
        <p class="title">教育经历</p>
        <div
          class="word-record-item"
          v-for="(item, index) in educationalExperience"
          :key="index"
        >
          <div class="row2">
            {{ item.schoolName
            }}<span style="margin-left: 20px"
              >{{ item.isOverseasStudy || "无" }}海外留学经历</span
            >
          </div>
          <div class="row1">
            在校时间：{{ item.intakeTime + "~" + item.graduateTime }}
          </div>
          <div class="row1">
            {{ item.educationalBackground }}<span class="line"></span>
            {{ item.major }}<span class="line"></span
            ><span> {{ ["无", "有"][item.diploma] }}学位证书</span>
            <span class="line" v-if="item.graduateTime == '至今'"></span>
            <w style="margin-left: 12px" v-if="item.graduateTime == '至今'">{{
              "在读#" + getEducationOptions(item.grade)
            }}</w>
          </div>
        </div>
      </section>
      <!-- 工作/实习经历 -->
      <section class="block pt30">
        <p class="title">工作/实习经历</p>
        <div
          class="word-record-item"
          v-for="(item, index) in workExperience"
          :key="index"
        >
          <div class="row1">
            {{ item.entryTime }}~{{ item.resignationTime }}
          </div>
          <div class="row2">{{ item.companyName }}</div>
          <div class="row3">{{ item.jobName }}</div>
          <div class="row4">
            <span class="label">职位类型</span
            ><span class="value">{{ ["实习", "全职"][item.jobType] }}</span>
            <span class="label">所属行业</span
            ><span class="value">{{ item.industry }}</span>
          </div>
          <div
            class="row5"
            v-if="item.jobDescription"
            v-html="item.jobDescription.replace(/\n/gm, '<br>')"
          ></div>
        </div>
      </section>
      <!-- 项目经历 -->
      <section class="block pt30">
        <p class="title">项目经历</p>
        <div
          class="word-record-item"
          v-for="(item, index) in projectExperience"
          :key="index"
        >
          <div class="row1">{{ item.beginTime }}~{{ item.endTime }}</div>
          <div class="row2">{{ item.projectName }}</div>
          <div
            class="row5"
            v-if="item.projectDescription"
            v-html="item.projectDescription.replace(/\n/gm, '<br>')"
          ></div>
        </div>
      </section>
      <!-- 语言能力 -->
      <section class="block pt30">
        <p class="title">语言能力</p>
        <div
          class="word-record-item"
          v-for="(item, index) in languageAbility"
          :key="index"
        >
          <div class="row2">
            {{ item.languageName }}<span>{{ item.level }}</span>
          </div>
        </div>
      </section>
      <!-- 专业技能 -->
      <section class="block pt30">
        <p class="title">专业技能</p>
        <div
          class="word-record-item"
          v-for="(item, index) in specialtyAbility"
          :key="index"
        >
          <div class="row2">
            {{ item.specialtyName }}<span>{{ item.level }}</span>
          </div>
        </div>
      </section>
      <!-- 证书 -->
      <section class="block pt30">
        <p class="title">证书</p>
        <div
          class="word-record-item"
          v-for="(item, index) in certificates"
          :key="index"
        >
          <div class="row2">
            {{ item.certificatesName }}<span>{{ item.time }}</span>
          </div>
        </div>
      </section>
      <!-- 已修课程 -->
      <section class="block pt30">
        <p class="title">已修课程</p>
        <div
          class="word-record-item"
          v-for="(item, index) in courses"
          :key="index"
        >
          <div class="row1">{{ item.time }}</div>
          <div class="row2">{{ item.coursesName }}</div>
        </div>
      </section>
      <!-- 社会实践/活动经历 -->
      <section class="block pt30">
        <p class="title">社会实践/活动经历</p>
        <div
          class="word-record-item"
          v-for="(item, index) in practiceExperience"
          :key="index"
        >
          <div class="row1">{{ item.beginTime }}~{{ item.endTime }}</div>
          <div class="row2">{{ item.practiceName }}</div>
          <div
            class="row5"
            v-if="item.practiceDescription"
            v-html="item.practiceDescription.replace(/\n/gm, '<br>')"
          ></div>
        </div>
      </section>
    </section>
  </PageCom>
</template>
<script>
import PageCom from "@/components/page/index.vue";
import { mapState } from "vuex";
import { getAge } from "@/utils/utils";
import { educationOptions } from "@/utils/frontDataDict.js";
export default {
  // 组件名称
  name: "demo",
  // 组件参数 接收来自父组件的数据
  props: {
    hideEdit: {
      type: Boolean,
      default: () => false,
    },
  },
  // 局部注册的组件
  components: { PageCom },
  // 组件状态值
  data() {
    return {
      userInfo: {},
      internshipDesire: [], //实习意向
      educationalExperience: [], //教育经历列表
      workExperience: [], //工作、实习经历列表
      projectExperience: [], //项目经历列表
      languageAbility: [], //语言能力列表
      specialtyAbility: [], //专业技能列表
      certificates: [], //证书列表
      courses: [], //已修课程列表
      practiceExperience: [], //实践经验
    };
  },
  // 计算属性
  computed: {
    ...mapState(["USER_INFO", "curriculumId", "userMobile"]),
  },
  // 组件方法
  methods: {
    linkTo(routeName) {
      this.$router.push({ name: routeName });
    },
    fetchJSON(str, key) {
      if (!str) return [];
      let arr = JSON.parse(str);
      if (arr.length <= 0) return [];
      this[key] = arr;
    },
    getEducationOptions(id) {
      let val = "";
      educationOptions.forEach((e) => {
        if (!e.children) return;
        let list = e.children.filter((v) => v.value == id);
        list.length > 0 && (val = list[0].label);
      });
      return val;
    },
    open(data) {
      if (data) {
        this.USER_INFO.birthday &&
          (this.USER_INFO.age = getAge(this.USER_INFO.birthday) + "岁");
        this.userInfo = this.USER_INFO;
        this.fetchJSON(data.internshipDesire, "internshipDesire");
        this.educationalExperience = data.educationalExperience;
        // this.fetchJSON(data.educationalExperience, "educationalExperience");
        this.fetchJSON(data.workExperience, "workExperience");
        this.fetchJSON(data.projectExperience, "projectExperience");
        this.fetchJSON(data.languageAbility, "languageAbility");
        this.fetchJSON(data.specialtyAbility, "specialtyAbility");
        this.fetchJSON(data.certificates, "certificates");
        this.fetchJSON(data.courses, "courses");
        this.fetchJSON(data.practiceExperience, "practiceExperience");
      }
    },
  },
};
</script>
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style lang="less" scoped>
.resume-review {
  position: relative;
  width: 100%;
  background: #f5f8fa;
  .edit-btn {
    position: absolute;
    top: 30px;
    right: 30px;
  }
  .block {
    position: relative;
    background: #fff;
    margin-bottom: 20px;
  }
  .pt30 {
    padding: 30px 40px;
  }
  .head-icon {
    position: relative;
    background: url("../../../assets/images/blue_bg.png") no-repeat center
      center / cover;
    width: 100%;
    height: 180px;
    > img {
      display: block;
      width: 64px;
      height: 64px;
      position: absolute;
      left: 50%;
      bottom: 0;
      transform: translate3d(-50%, 50%, 0);
      overflow: hidden;
    }
  }
  .user-info {
    position: relative;
    padding: 73px 0 120px;
    text-align: center;
    .row1 {
      position: relative;
      line-height: 50px;
      font-weight: 600;
      color: #37383d;
      font-size: 36px;
      text-align: center;
      margin-bottom: 12px;
      span {
        display: inline-block;
        border-radius: 6px;
        border: 1px solid #2f8efe;
        font-size: 20px;
        font-weight: 400;
        color: #2f8efe;
        line-height: 36px;
        padding: 0 12px;
        margin-left: 12px;
        vertical-align: middle;
        // &.line{
        //   position: relative;
        //   display: inline-block;
        //   width: 1px;
        //   height: 14px;
        //   background: #9597a0;
        //   margin: 0 18px;
        // }
      }
    }
    .row2 {
      position: relative;
      display: inline-block;
      text-align: center;
      font-size: 20px;
      font-family: PingFangSC-Regular, PingFang SC;
      font-weight: 400;
      color: #9597a0;
      line-height: 28px;
      .line {
        position: relative;
        display: inline-block;
        width: 1px;
        height: 14px;
        background: #9597a0;
        margin: 0 18px;
      }
    }
    .row3 {
      position: absolute;
      display: inline-block;
      left: 0;
      top: 49px;
      width: 100%;
      text-align: left;
      font-size: 20px;
      font-family: PingFangSC-Regular, PingFang SC;
      font-weight: 400;
      color: #37383d;
      line-height: 28px;
      margin-top: 21px;
      .label {
        position: relative;
        display: inline-block;
        width: 60%;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
      }
      .label:first-child {
        width: 40%;
      }
    }
    .row4 {
      position: absolute;
      display: inline-block;
      left: 0;
      top: 92px;
      width: 100%;
      text-align: left;
      font-size: 20px;
      font-family: PingFangSC-Regular, PingFang SC;
      font-weight: 400;
      color: #37383d;
      line-height: 28px;
      margin-top: 21px;
      .label {
        position: relative;
        display: inline-block;
        width: 60%;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
      }
      .label:first-child {
        width: 40%;
      }
    }
  }
  .title {
    font-size: 28px;
    font-family: PingFangSC-Medium, PingFang SC;
    font-weight: 500;
    color: #37383d;
    line-height: 40px;
    margin: 0 0 30px;
    padding: 0;
  }
  .job-wish-item {
    .row1 {
      font-size: 24px;
      font-family: PingFangSC-Regular, PingFang SC;
      font-weight: 400;
      color: #37383d;
      line-height: 33px;
      margin-bottom: 20px;
      .line {
        position: relative;
        display: inline-block;
        width: 1px;
        height: 17px;
        background: #9597a0;
        margin: 0 25px;
      }
    }
    .job-type {
      font-size: 20px;
      font-family: PingFangSC-Regular, PingFang SC;
      font-weight: 400;
      color: #37383d;
      line-height: 28px;
    }
  }
  .word-record-item {
    padding-bottom: 27px;
    border-bottom: 1px solid #d4d6da;
    margin-bottom: 30px;
    &:last-child {
      padding-bottom: 0;
      margin-bottom: 0;
      border-bottom: 1px solid #fff;
    }
    .row1 {
      font-size: 20px;
      font-family: PingFangSC-Regular, PingFang SC;
      font-weight: 400;
      color: #9597a0;
      line-height: 28px;
      margin-bottom: 15px;
    }
    .row2 {
      font-size: 24px;
      font-family: PingFangSC-Medium, PingFang SC;
      font-weight: 500;
      color: #37383d;
      line-height: 33px;
      margin-bottom: 15px;
      span {
        font-size: 24px;
        font-family: PingFangSC-Medium, PingFang SC;
        font-weight: 500;
        color: #9597a0;
        line-height: 33px;
        margin-left: 218px;
      }
    }
    .row3 {
      font-size: 20px;
      font-family: PingFangSC-Regular, PingFang SC;
      font-weight: 400;
      color: #9597a0;
      line-height: 28px;
      margin-bottom: 15px;
      .line {
        position: relative;
        display: inline-block;
        width: 1px;
        height: 17px;
        background: #9597a0;
        margin: 0 25px;
      }
    }
    .row4 {
      margin-bottom: 20px;
      .label {
        font-size: 20px;
        font-family: PingFangSC-Regular, PingFang SC;
        font-weight: 400;
        color: #9597a0;
        line-height: 28px;
        margin-right: 17px;
      }
      .value {
        font-size: 20px;
        font-family: PingFangSC-Regular, PingFang SC;
        font-weight: 400;
        color: #030303;
        line-height: 28px;
        margin-right: 130px;
      }
    }
    .row5 {
      font-size: 20px;
      font-family: PingFangSC-Regular, PingFang SC;
      font-weight: 400;
      color: #3c3c3c;
      line-height: 37px;
    }
  }
}
</style>
